<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-show</title>
</head>
<body>
    <div id="app">
        <h1>{{ title }}</h1>
        <div>
            {{ web.show }}
        </div>
        <button @click="toggle">切换显示状态</button>

        <p v-show="web.show">这是一段可以隐藏的文字</p>
    </div>

    <script type="module">
        import {createApp, reactive} from './js/vue.esm-browser.js'

        createApp({
            // setup选项，用于设置响应式数据和方法等 
            setup() {
                // reactive 创建响应式对象，用于存储复杂的数据类型，例如：对象、数组
                const web = reactive({
                    title: "百度",
                    url: "https://www.baidu.com",
                    number: 0,
                    show: true
                })

                const toggle = () => {
                    web.show = !web.show
                }

                return {
                    title: "v-show",
                    web,
                    toggle
                }
            }
        }).mount("#app")
    </script>
</body>
</html>